import { defineStore } from 'pinia'
import type { DoGetStoreInfoByShopAssistantPhoneResponse } from '@/apis/home/model'
import storage from '@/utils/storage'

export const useStoreInfoStore = defineStore('storeStore', {
  state: () => {
    return {
      shopStoreInfo: storage.get('shop_store_info') || {},
    }
  },
  actions: {
    SET_STORE_INFO(payload: DoGetStoreInfoByShopAssistantPhoneResponse) {
      this.shopStoreInfo = payload
      storage.set('shop_store_info', payload)
    },
    REMOVE_STORE_INFO() {
      this.shopStoreInfo = {}
      storage.remove('shop_store_info')
    },
  },
  getters: {
    storeId: (state) => state.shopStoreInfo.id,
  },
})
